function distance = getDistance(A, B)

% A, B are coordinates to compute distances for; each one should have two
% columns, representing x and y; each row represents one point.

if size(B, 1) == 1 && size(A, 1) ~= 1
    % if B is only one point but A is an array having multiple points
    B_array = ones(size(A));
    B_array(:, 1) = B(1);
    B_array(:, 2) = B(2);
    distance = sqrt(sum((A - B_array).^2, 2));
else
    distance = sqrt(sum((A - B).^2, 2));
end